<%-- 
    Document   : mappaPosti
    Created on : 8-mag-2014, 17.03.11
    Author     : Marco
--%>

<%@page import="java.util.List"%>
<%@page import="ejb.StatusPosto"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <title>SportingEventClub - Posti</title>
        <link rel="stylesheet" type="text/css" href="CSS/BaseSite.css" />
        <link rel="stylesheet" type="text/css" href="CSS/vertical-ticker.css"/>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <script type="text/javascript" src="JQuery/selezionaposti.js"></script>
        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
        <script type="text/javascript" src="JQuery/jquery.totemticker.js"></script>
        <link rel="shortcut icon" href= "Images/stadion-icon.png"/>
    </head>
    <body> 
        <div class="main">
            <div class="page">
                <div class="header">       
                    <div class="login">
                        <%@include file="login.jsp"%>
                    </div>
                    <div class="banner">
                    </div>
                    <div class="topmenu">
                        <%@include file="topmenu.jsp" %>
                    </div>
                </div>
                <div class="content">
                    <div class="content-in">
                        <div class="left-panel">
                            <div class="left-panel-in">
                            <%session = request.getSession();
                                  String login = (String) session.getAttribute("nomeUtente");
                                  if(login==null){
                            %>
                                    <%@include file="erroresession.jsp"%>    
                            <%}else{%>
                                <div id="dialogoverlay"></div>
                                <div id="dialogbox">
                                    <div>
                                      <div id="dialogboxhead"></div>
                                      <div id="dialogboxbody"></div>
                                      <div id="dialogboxfoot"></div>
                                    </div>
                                </div>
                                <h1 style="text-align:center;">Seleziona il posto desiderato:</h1>
                                <table border="0" style="text-align:center; padding-left:10px;">
                                    <thead>
                                        <tr>
                                            <th></th>
                                            <th>1</th>
                                            <th>2</th>
                                            <th>3</th>
                                            <th>4</th>
                                            <th>5</th>
                                            <th>6</th>
                                            <th>7</th>
                                            <th>8</th>
                                            <th>9</th>
                                            <th>10</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <%
                                            int i = 0;
                                            int fila = 1;
                                            int posti = 1;
                                            String[] file = {"A", "B", "C", "D", "E"};
                                            int k = -1;
                                            List<StatusPosto> idposti = (List<StatusPosto>)request.getAttribute("idposti");
                                            while(i<idposti.size()){
                                                if(fila==1){
                                                    k++;
                                        %>
                                                <tr>
                                                    <td><h4><%=file[k]%></h4></td>
                                                    <%}
                                                    String np = posti + "-" + file[k];
                                                    if(idposti.get(i).getStato().equals("prenotato")){
                                                    %>
                                                        <td><button type='button' id='poltrona<%=np%>' style="background-color:red" onclick="return selezionaPosto('<%=np%>');"><img src = "Images/poltrona.png" width="50px" height="50px" style="margin-top:10px;"/></button></td>
                                                    <%}else{%>
                                                        <td><button type='button' id='poltrona<%=np%>' style="background-color:green" onclick="return selezionaPosto('<%=np%>');"><img src = "Images/poltrona.png" width="50px" height="50px" style="margin-top:10px;"/></button></td>                                                            
                                                    <%}
                                                        if(posti==10){%>
                                                </tr>
                                                    <%  
                                                            posti = 0;
                                                            fila = 0;
                                                        }
                                                        ++i;
                                                        ++posti;
                                                        ++fila;
                                            }
                                                    %>    
                                    </tbody>
                                </table>
                                <br/><br/><br/>
                                <table>
                                    <tr>
                                        <td><img src="Images/libero.jpg" width="30px" height="30px"/>&nbsp;&nbsp;&nbsp;&nbsp;Posto libero</td>
                                    </tr>
                                    <tr>
                                        <td><img src="Images/prenotato.jpg" width="30px" height="30px"/>&nbsp;&nbsp;&nbsp;&nbsp;Posto occupato</td>
                                    </tr>
                                    <tr>
                                        <td><img src="Images/selezionato.jpg" width="30px" height="30px"/>&nbsp;&nbsp;&nbsp;&nbsp;Posto selezionato</td>
                                    </tr>
                                </table>
                                <form name="selezionaPosti" action="GeneralController" method="post" onsubmit="return checkPrenotazione();">
                                    <%request.setAttribute("settore", request.getAttribute("settore"));%>
                                    <input type='hidden' id='settore' name="settore" value="<%=request.getAttribute("settore")%>"/>
                                    <input type='hidden' id='evento' name="evento"  value="<%=request.getAttribute("idevento")%>"/>
                                    <input type='hidden' id='postiselezionati' name="postiselezionati" value=""/>
                                    <button type="submit" name="submit" class="myButton blue" value="prenotaPosti" style="margin-left:450px; margin-bottom:20px;">Prenota</button>
                                </form>
                            <%}%>
                            </div>
                        </div>
                        <div class="right-panel">
                            <div class="right-panel-in">
                                <jsp:include page="/GeneralController">
                                    <jsp:param name="submit" value="right-content"/>
                                    <jsp:param name="op" value="newsbox"/>
                                </jsp:include>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="footer">
                    <%@include file="footer.jsp" %> 
                </div>
            </div>
        </div> 
    </body>
</html>
